const _ = require("lodash")

// 函数组合
function compose(f, g) {
    return function (value) {
        return f(g(value))
    }
}

function reverse(arr) {
    return arr.reverse()
}

function first(arr) {
    return arr[0]
}

const last = compose(first, reverse)

const arr = [1,6,3,4,5,2]
// console.log(last(arr))

const addOne = (arr) => arr.map(item => item+1)
const filter = (arr) => arr.filter(item => item>2)
const sort = (arr) => arr.sort((a,b) => a-b)
console.log(sort(filter(addOne(arr))))